$(function() {
		
		var obj = {
			subject : "",//获得学科
			grade : "",//获的年级
			area : "",//地区
			sex : "",//性别
			teacherage : "",//教龄
			education : "",//学历要求
			type : "",//身份要求  ..高校学生还是在职
			workType:"",//工作方式
			page:""

		}

		function param() {

			obj.subject = $(".one").find(".chosen").attr("name");//获得学科
			obj.grade = $(".two").find(".chosen").attr("name");//获的年级
			obj.area = $(".three").find(".chosen").attr("name");//地区
			obj.sex = $(".four").find(".chosen").attr("name");//性别
			obj.teacherage = $(".five").find(".chosen").attr("name");//教龄
			obj.education = $(".six").find(".chosen").attr("name");//学历要求
			obj.type = $(".seven").find(".chosen").attr("name");//身份要求  ..高校学生还是在职
			obj.workType=$(".eight").find(".chosen").attr("name")
		}
		//ajax通用请求
		function myajax(num) {//...這個
			$
					.ajax({
						type : "post",
						url : "/GDZjiajiaowang/serchTea",
						data : {
							"subject" : obj.subject,
							"grade" : obj.grade,
							"area" : obj.area,
							"sex" : obj.sex,
							"teacherage" : obj.teacherage,
							"education" : obj.education,
							"type" : obj.type,
							"workType":obj.workType,
							"page" : num
						},
						dataType : "json",
						success : function(data) {
							$.each(
											data.teacherLsit,
											function(index, tea) {
												var div = "<a href='/GDZjiajiaowang/TeacherInfoServlet?teacherId="+tea.id+"'>" ;
													div+=	"<div class='teacher_list_div'>";
												div += "<img src="+tea.img+" width='178' height='193'/>";
												div += "<p><span>"
														+ tea.realName
														+ "</span></p>";
												div += "<p><span>"
														+ tea.education
														+ "</span><span>|</span><span>"
														+ tea.teacherYear
														+ "教龄</span></p>"+
														"<label class='sg'>教授科目:"+tea.subject+"</label></br><label class='sg'>教授年級:"+tea.grade+"</label> ";
												div += "<p>" + tea.selfMark
														+ "</p></div></a>";

												$(".main_line_four")
														.append(div);

											});
							
							//分頁插件的.................................!!!!!!!!>!>!>!>!>!>>!
							$("#page").paging({
								pageNo: num,
								totalPage: data.totalPage,
								totalSize: data.totalCount,
								callback: function(num) {
									myajax(num);
								}
							})

						},
						beforeSend : function() {
							$(".main_line_four").empty();

						}
					});
		}
		//页面加载的时候
			param();
			obj.page = "1";
			myajax();
		
		// 上方复选 条件
		$(".main_line_three li").click(function() {

			$(this).attr("name", $(this).text());
			$(this).siblings().css({
				"background-color" : "#e7f5f5",
				"color" : "#6C6C6C"
			});
			$(this).css({
				"background-color" : "#65C2C7",
				"color" : "white"
			});
			$(this).siblings().removeClass("chosen");
			$(this).addClass("chosen");
			param();
			obj.page = "1";
			
			myajax(obj.page);

		});

		//下方 页码
		$(".main_line_five_inside span").click(function() {
			obj.page = $(this).attr("pd")
			myajax(obj.page);
		});
		//页码的输入框
		$(".main_line_five_inside input").change(function() {
			obj.page = $(this).val();
			myajax(obj.page);

		});
		
		
		
		//分頁插件 ...................................................!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		
	})